package lex.proxyverfier.actions;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Collection;

import org.lex.net.proxy.ProxyServer;
import org.lex.net.proxy.ProxyServerUtils;

import lex.proxyverfier.ProxyTableModel;
import lex.proxyverfier.ProxyVerifier;

public class ImportExportOperations
{
	public static void importProxyServers( Collection<ProxyServer> servers )
	{
		ProxyTableModel pm = ProxyVerifier.getApplication().getProxyManager();
		for( ProxyServer server : servers )
			pm.put( server );
	}
	
	public static void exportPlain( Collection<ProxyServer> servers, File file ) throws IOException
	{
		if( false == file.exists() || false == file.isFile() )
			file.createNewFile();
		FileWriter out = new FileWriter(file, false);
		ProxyServerUtils.exportPlain( servers, out );
	}
}
